package com.qidian.mes.produce.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.Craft;
import com.qidian.mes.produce.service.CraftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 陈俊成
 * @Company ccc
 * @Description
 * @Time 2024/10/19 13:37
 */
@RestController
@RequestMapping("/craft")
@CrossOrigin
public class CraftController {
    @Autowired
    CraftService craftService;
    @GetMapping("/getList")
    public MESResult getList(Craft craft, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return craftService.queryList(craft,page,limit);
    }

    @PostMapping("/addCraft")
    public MESResult addCraft(@RequestBody Craft craft){
        return craftService.addCraft(craft);
    }

    @DeleteMapping("/delete")
    public MESResult deleteCraft(int craftRelId){
        return  craftService.deleteCraft(craftRelId);
    }

    @GetMapping("/getPrimary")
    public MESResult getPrimary(int craftRelId){
        return craftService.getPrimary(craftRelId);
    }

    @PutMapping("/primary")
    public MESResult primaryCraft(@RequestBody Craft craft){
        System.out.println("ssdqdqwdqdwwq"+craft);
        return craftService.primaryCraft(craft);
    }
}
